import { Skill, SkillType } from "@/core/skill"

const MARIONETTE_BUFF_DATA = [
    0, 43, 57, 74, 91, 111, 131, 153, 176, 201, 228, 255, 284, 315, 346, 379, 414, 449, 487, 526, 567, 608, 651, 696, 741, 789, 838, 888, 939, 993, 1047, 1103, 1160, 1219, 1278, 1340, 1403, 1467,
    1533, 1600, 1668
]

const MARIONETTE_ATTACK_DATA = [
    0, 68740, 84680, 100619, 116559, 132498, 148440, 164380, 180320, 196259, 212200, 228140, 244079, 260019, 275958, 291898, 307839, 323778, 339718, 355658, 371597, 387537, 403479, 419419, 435358,
    451298, 467237, 483177, 499118, 515057, 530997, 546937, 562876, 578816, 594757, 610696, 626636, 642576, 658516, 674457, 690397
]

const Marionette: Skill = {
    name: "marionette", // 开幕！人偶剧场
    level_spacing: 5,
    level_master: 30,
    level_max: 40,
    need_level: 50,
    cooldown: 170,
    type: SkillType.AWAKE,
    effect({ level, adapt_number }, { buff_entry }) {
        const { awake_level_add, awake_intstr_add, awake_intstr_per } = buff_entry

        level = level.plus(awake_level_add)

        const mp = adapt_number.divide(750).plus(1).multiply(awake_intstr_per.plus(1))

        const intstr = MARIONETTE_BUFF_DATA[level].plus(awake_intstr_add).multiply(mp)

        return {
            level,
            adapt_number,
            value: {
                intstr
            },
            frames: [
                {
                    attack: MARIONETTE_ATTACK_DATA[level],
                    hits: 1
                }
            ],
            data: [intstr]
        }
    }
}

const FORESTOFDOLLS_ATTACK_DATA_0 = [
    0, 8358, 10296, 12235, 14173, 16110, 18049, 19987, 21925, 23863, 25802, 27740, 29677, 31617, 33554, 35492, 37431, 39369, 41307, 43245, 45184, 47121, 49059, 50998, 52936, 54874, 56813, 58751,
    60689, 62626, 64565, 66503, 68441, 70380, 72318, 74256, 76195, 78132, 80070, 82008, 83947, 85885, 87823, 89762, 91700, 93637, 95576, 97514, 99452, 101390, 103329, 105267, 107204, 109143, 111081,
    113019, 114957, 116896, 118834, 120772, 122711, 124648, 126586, 128525, 130463, 132401, 134339, 136278, 138215, 140153, 142092
]

const FORESTOFDOLLS_ATTACK_DATA_1 = [
    0, 29255, 36038, 42822, 49605, 56389, 63172, 69956, 76739, 83523, 90306, 97090, 103874, 110657, 117441, 124224, 131008, 137791, 144576, 151358, 158143, 164926, 171710, 178494, 185277, 192061,
    198844, 205628, 212411, 219195, 225978, 232762, 239545, 246329, 253114, 259897, 266681, 273464, 280248, 287031, 293815, 300598, 307382, 314165, 320949, 327732, 334516, 341300, 348083, 354867,
    361650, 368435, 375217, 382002, 388785, 395569, 402352, 409136, 415920, 422703, 429487, 436270, 443054, 449837, 456621, 463404, 470188, 476971, 483755, 490540, 497323
]

const FORESTOFDOLLS_ATTACK_DATA_2 = [
    0, 78011, 96101, 114190, 132279, 150369, 168460, 186548, 204637, 222728, 240817, 258907, 276996, 295086, 313175, 331266, 349354, 367444, 385534, 403624, 421715, 439803, 457892, 475983, 494072,
    512162, 530251, 548341, 566430, 584521, 602609, 620699, 638789, 656879, 674968, 693058, 711147, 729237, 747327, 765416, 783505, 801596, 819685, 837775, 855864, 873954, 892043, 910134, 928222,
    946311, 964402, 982492, 1000581, 1018671, 1036760, 1054849, 1072940, 1091030, 1109118, 1127209, 1145298, 1163389, 1181477, 1199566, 1217657, 1235747, 1253836, 1271925, 1290015, 1308104, 1326195
]

/**
 *  欢迎来到人偶之森
 */
const ForestOfDolls: Skill = {
    name: "forest_of_dolls",
    level_spacing: 5,
    level_master: 30,
    level_max: 40,
    need_level: 85,
    cooldown: 180,
    point: 200,
    type: SkillType.AWAKE,
    effect({ level }) {
        return {
            frames: [
                {
                    attack: FORESTOFDOLLS_ATTACK_DATA_0[level],
                    hits: 7
                },
                {
                    attack: FORESTOFDOLLS_ATTACK_DATA_1[level],
                    hits: 2
                },
                {
                    attack: FORESTOFDOLLS_ATTACK_DATA_2[level],
                    hits: 1
                }
            ]
        }
    }
}

const CURTAINCALL_ATTACK_DATA_0 = [
    0, 5726, 7053, 8382, 9709, 11036, 12364, 13693, 15021, 16348, 17675, 19003, 20331, 21660, 22987, 24314, 25643, 26970, 28298, 29626, 30953, 32282, 33609, 34937, 36264, 37593, 38921, 40248, 41576,
    42903, 44232, 45560, 46887, 48215, 49542, 50871, 52198, 53527, 54854, 56181, 57510, 58837, 60166, 61493, 62821, 64149, 65476, 66803, 68132, 69461, 70788, 72115, 73442, 74771, 76100, 77427, 78754,
    80082, 81410, 82737, 84066, 85393, 86721, 88049, 89376, 90704, 92032, 93361, 94688, 96016, 97343
]

const CURTAINCALL_ATTACK_DATA_1 = [
    0, 22903, 28215, 33526, 38837, 44149, 49460, 54771, 60083, 65392, 70704, 76016, 81326, 86638, 91950, 97260, 102572, 107882, 113194, 118505, 123816, 129128, 134439, 139750, 145061, 150371, 155683,
    160995, 166305, 171617, 176929, 182239, 187550, 192862, 198172, 203484, 208796, 214106, 219418, 224728, 230040, 235351, 240662, 245974, 251285, 256596, 261908, 267217, 272529, 277841, 283151,
    288463, 293775, 299085, 304396, 309708, 315018, 320330, 325642, 330952, 336264, 341576, 346886, 352197, 357508, 362820, 368131, 373442, 378754, 384063, 389375
]

const CURTAINCALL_ATTACK_DATA_2 = [
    0, 343566, 423233, 502902, 582569, 662237, 741904, 821572, 901240, 980908, 1060575, 1140243, 1219910, 1299579, 1379246, 1458915, 1538582, 1618250, 1697918, 1777586, 1857253, 1936921, 2016588,
    2096257, 2175924, 2255592, 2335259, 2414927, 2494595, 2574263, 2653930, 2733598, 2813265, 2892934, 2972601, 3052269, 3131936, 3211605, 3291272, 3370940, 3450607, 3530274, 3609943, 3689611,
    3769278, 3848945, 3928613, 4008282, 4087949, 4167616, 4247284, 4326951, 4406620, 4486287, 4565955, 4645622, 4725290, 4804958, 4884626, 4964293, 5043961, 5123629, 5203297, 5282964, 5362632,
    5442299, 5521968, 5601635, 5681303, 5760970, 5840638
]

const CurtainCall: Skill = {
    name: "curtain_call", // 终幕！人偶剧场
    level_spacing: 5,
    level_master: 30,
    level_max: 40,
    need_level: 100,
    cooldown: 290,
    type: SkillType.AWAKE,
    effect({ level, useSkill }) {
        const awake = useSkill(Marionette.name)
        const mp = level.multiply(0.01).plus(0.23)
        if (!!awake) {
            let intstr = awake().value?.intstr ?? 0
            intstr = intstr.multiply(mp)
            return {
                value: {
                    intstr
                },
                frames: [
                    {
                        attack: CURTAINCALL_ATTACK_DATA_0[level],
                        hits: 8
                    },
                    {
                        attack: CURTAINCALL_ATTACK_DATA_1[level],
                        hits: 3
                    },
                    {
                        attack: CURTAINCALL_ATTACK_DATA_2[level],
                        hits: 1
                    }
                ]
            }
        }
    }
}

export default [Marionette, ForestOfDolls, CurtainCall]
